<?php

// #################################################################### ||
// #                                                                  # ||
// #   MySmartBB Version 1.5.0 Updating script                        # ||
// #   http://www.MySmartBB.com                                       # ||
// #   Copyright (c) 2005 by MySmartBB team                           # ||
// #                                                                  # ||
// #   filename : update1.5.0.php                                     # ||
// #   Updating MySmartBB forum  to version 1.5.0                     # ||
// #                                                                  # ||
// #################################################################### ||

// ** General definitions **


      define('install',1);
      include('../common.php');

echo'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="ar" dir="rtl">
<head>

<style type="text/css">
body { background-color: #EBEBEB; margin: 0px 0px 0px 0px;}
</style>

  <title>مرحباً بك في ملف ترقية برنامج المنتدى العربي MySmartBB 1.5.0</title>
  <link rel="stylesheet" href="style.css" type="text/css" />
  <meta http-equiv="Content-Type" content="text/html; charset=windows-1256" />
</head>

<body>
<div align="center">
  <table border="0" cellspacing="1" class="border" summary="الهيدر" width="100%">
     <tr>
      <td width="100%" colspan="7" style="background: url(theme/header_bg.gif) repeat-x ;height:118px;"><img alt="{$board_title}" border="0" src="theme/logo.gif" height="118" /></td>
    </tr>
    <tr>
      <td class="tcat">معالج ترقية برنامج المنتدى العربي MySmartBB 1.5.0</td>
    </tr>
  </table>

  <br />

  <div align="center">
  <table class="border" summary="المحتويات" border="0" cellpadding="0" cellspacing="1" width="98%">
    <tr>
      <td class="context">

                <br />';

      $info_query = $DB->sql_query("SELECT * FROM " . $db_prefix . "info WHERE id='1'");
      $info_row   = $DB->sql_fetch_array($info_query);

      if (empty($_GET['step'])) { $step = 1; }

      if ($step == 1)
      {
          if ($info_row['MySBB_version'] != "1.1.3")
          {
              $SF->error('يجب ان يكون الاصدار 1.1.3 لكي يتم تحديثه');
          }

          $query = array("ALTER TABLE `MySBB_announcement` RENAME `" . $db_prefix . "announcement`",
                         "ALTER TABLE `MySBB_attach` RENAME `" . $db_prefix . "attach`",
                         "ALTER TABLE `MySBB_avater` RENAME `" . $db_prefix . "avater`",
                         "ALTER TABLE `MySBB_banned` RENAME `" . $db_prefix . "banned`",
                         "ALTER TABLE `MySBB_contactus_extensions` RENAME `" . $db_prefix . "contactus_extensions`",
                         "ALTER TABLE `MySBB_contactus_messages` RENAME `" . $db_prefix . "contactus_messages`",
                         "ALTER TABLE `MySBB_emailmsgs` RENAME `" . $db_prefix . "emailmsgs`",
                         "ALTER TABLE `MySBB_ex` RENAME `" . $db_prefix . "ex`",
                         "ALTER TABLE `MySBB_group` RENAME `" . $db_prefix . "group`",
                         "ALTER TABLE `MySBB_info` RENAME `" . $db_prefix . "info`",
                         "ALTER TABLE `MySBB_member` RENAME `" . $db_prefix . "member`",
                         "ALTER TABLE `MySBB_online` RENAME `" . $db_prefix . "online`",
                         "ALTER TABLE `MySBB_pages` RENAME `" . $db_prefix . "pages`",
                         "ALTER TABLE `MySBB_pm` RENAME `" . $db_prefix . "pm`",
                         "ALTER TABLE `MySBB_pmfolder` RENAME `" . $db_prefix . "pmfolder`",
                         "ALTER TABLE `MySBB_pmlists` RENAME `" . $db_prefix . "pmlists`",
                         "ALTER TABLE `MySBB_poll` RENAME `" . $db_prefix . "poll`",
                         "ALTER TABLE `MySBB_reply` RENAME `" . $db_prefix . "reply`",
                         "ALTER TABLE `MySBB_requests` RENAME `" . $db_prefix . "requests`",
                         "ALTER TABLE `MySBB_section` RENAME `" . $db_prefix . "section`",
                         "ALTER TABLE `MySBB_sectionadmin` RENAME `" . $db_prefix . "sectionadmin`",
                         "ALTER TABLE `MySBB_sectiongroup` RENAME `" . $db_prefix . "sectiongroup`",
                         "ALTER TABLE `MySBB_smiles` RENAME `" . $db_prefix . "smiles`",
                         "ALTER TABLE `MySBB_style` RENAME `" . $db_prefix . "style`",
                         "ALTER TABLE `MySBB_subject` RENAME `" . $db_prefix . "subject`",
                         "ALTER TABLE `MySBB_supermemberlogs` RENAME `" . $db_prefix . "supermemberlogs`",
                         "ALTER TABLE `MySBB_today` RENAME `" . $db_prefix . "today`",
                         "ALTER TABLE `MySBB_toolbox` RENAME `" . $db_prefix . "toolbox`",
                         "ALTER TABLE `MySBB_usertitle` RENAME `" . $db_prefix . "usertitle`",
                         "ALTER TABLE `MySBB_vote` RENAME `" . $db_prefix . "vote`",
                         "ALTER TABLE `MySBB_ads` RENAME `" . $db_prefix . "ads`",
                         "ALTER TABLE `" . $db_prefix . "info` ADD `toolbox_show` INT(1) DEFAULT '1' NOT NULL",
                         "ALTER TABLE `" . $db_prefix . "info` ADD `smiles_show` INT(1) DEFAULT '1' NOT NULL",
                         "ALTER TABLE `" . $db_prefix . "info` ADD `icons_show` INT(1) DEFAULT '1' NOT NULL",
                         "ALTER TABLE `" . $db_prefix . "info` ADD `title_quote` INT(1) DEFAULT '1' NOT NULL",
                         "ALTER TABLE `" . $db_prefix . "info` ADD `close_stick_activate` TINYINT(1) NOT NULL DEFAULT '1'",
                         "ALTER TABLE `" . $db_prefix . "info` ADD `timestamp` VARCHAR(6) NOT NULL DEFAULT '0000'",
                         "ALTER TABLE `" . $db_prefix . "info` ADD `timesystem` ENUM( 'normal', 'ty') NOT NULL DEFAULT 'ty'",
                         "ALTER TABLE `" . $db_prefix . "info` ADD `online_now_section` TINYINT(1) DEFAULT '1' NOT NULL",
                         "ALTER TABLE `" . $db_prefix . "info` ADD `online_now_subject` TINYINT(1) DEFAULT '1' NOT NULL",
                         "ALTER TABLE `" . $db_prefix . "info` ADD `confirm_on_change_mail` INT( 1 ) NOT NULL DEFAULT '0'",
                         "ALTER TABLE `" . $db_prefix . "info` ADD `confirm_on_change_pass` INT( 1 ) NOT NULL DEFAULT '0'",
                         "ALTER TABLE `" . $db_prefix . "info` ADD `resize_imagesAllow` TINYINT(1) NOT NULL",
                         "ALTER TABLE `" . $db_prefix . "info` ADD `default_imagesW` MEDIUMINT(4) NOT NULL",
                         "ALTER TABLE `" . $db_prefix . "info` ADD `default_imagesH` MEDIUMINT(4) NOT NULL",
                         "ALTER TABLE `" . $db_prefix . "info` ADD `allow_avatar` INT( 1 ) NOT NULL DEFAULT '1'",
                         "ALTER TABLE `" . $db_prefix . "info` ADD `allow_apsent` INT( 1 ) NOT NULL DEFAULT '1'",
                         "ALTER TABLE `" . $db_prefix . "info` ADD `max_avatar_width` INT( 5 ) NOT NULL DEFAULT '150'",
                         "ALTER TABLE `" . $db_prefix . "info` ADD `max_avatar_height` INT( 5 ) NOT NULL DEFAULT '150'",
                         "ALTER TABLE `" . $db_prefix . "info` ADD `banned_pemail` MEDIUMTEXT NOT NULL",
                         "ALTER TABLE `" . $db_prefix . "info` ADD `banned_email` MEDIUMTEXT NOT NULL",
                         "ALTER TABLE `" . $db_prefix . "info` ADD `banned_name` MEDIUMTEXT NOT NULL",
                         "ALTER TABLE `" . $db_prefix . "attach` ADD `u_id` INT( 9 ) NOT NULL",
                         "ALTER TABLE `" . $db_prefix . "attach` ADD `temp` VARCHAR( 250 ) NOT NULL",
                         "ALTER TABLE `" . $db_prefix . "group` ADD `download_attach_number` SMALLINT(4) NOT NULL DEFAULT '0'",
                         "ALTER TABLE `" . $db_prefix . "group` ADD `upload_attach_num` INT( 5 ) NOT NULL DEFAULT '5'",
                         "ALTER TABLE `" . $db_prefix . "group` ADD `min_send_pm` INT( 9 ) NOT NULL",
                         "ALTER TABLE `" . $db_prefix . "group` ADD `allow_see_offstyles` INT( 1 ) NOT NULL DEFAULT '0'",
                         "ALTER TABLE `" . $db_prefix . "style` ADD `style_on` INT( 1 ) DEFAULT '1' NOT NULL",
                         "ALTER TABLE `" . $db_prefix . "style` ADD `style_order` INT( 9 ) NOT NULL",
                         "ALTER TABLE `" . $db_prefix . "reply` ADD `keepmeon` INT( 1 ) DEFAULT '1' NOT NULL",
                         "ALTER TABLE `" . $db_prefix . "section` ADD `sig_iteration` INT( 1 ) DEFAULT '0' NOT NULL",
                         "ALTER TABLE `" . $db_prefix . "member` ADD `keepmeon` INT( 9 ) DEFAULT '1' NOT NULL",
                         "ALTER TABLE `" . $db_prefix . "member` CHANGE `away_msg` `away_msg` TINYTEXT NOT NULL",
                         "ALTER TABLE `" . $db_prefix . "member` CHANGE `user_time` `user_time` VARCHAR( 6 ) NOT NULL DEFAULT '0000'",
                         "ALTER TABLE `" . $db_prefix . "info` CHANGE `smiles_cache` `smiles_cache` MEDIUMTEXT NOT NULL",
                         "ALTER TABLE `" . $db_prefix . "info` CHANGE `forums_cache` `forums_cache` MEDIUMTEXT NOT NULL",
                         "ALTER TABLE `" . $db_prefix . "info` CHANGE `sectiongroup_cache` `sectiongroup_cache` MEDIUMTEXT NOT NULL",
                         "ALTER TABLE `" . $db_prefix . "info` CHANGE `subforums_cache` `subforums_cache` MEDIUMTEXT NOT NULL",
                         "ALTER TABLE `" . $db_prefix . "member` CHANGE `away_msg` `away_msg` tinytext NOT NULL",
                         "ALTER TABLE `" . $db_prefix . "subject` DROP `report`",
                         "ALTER TABLE `" . $db_prefix . "info` DROP `upfile_size`",
                         "update " . $db_prefix . "group set title='مدير المنتدى', username_style='" . addslashes('<strong><em><span style="color: #800000;">[username]</span></em></strong>') . "' WHERE id='1'",
                         "update " . $db_prefix . "group set title='نائب المدير', username_style='" . addslashes('<strong><span style="color: #FF0000;">[username]</span></strong>') . "' WHERE id='2'",
                         "update " . $db_prefix . "group set title='مشرف', username_style='" . addslashes('<strong><span style="color: #0000FF;">[username]</span></strong>') . "' WHERE id='3'",
                         "update " . $db_prefix . "group set title='عضو', username_style='" . addslashes('<span style="color: #000000;">[username]</span>') . "' WHERE id='4'",
                         "update " . $db_prefix . "group set title='على قائمة الإنتظار', username_style='" . addslashes('<span style="color: #008080;">[username]</span>') . "' WHERE id='5'",
                         "update " . $db_prefix . "group set title='موقوف', username_style='" . addslashes('<span style="color: #FF0000;">[username]</span>') . "' WHERE id='7'",
                         "update " . $db_prefix . "group set title='المراقب العام', username_style='" . addslashes('<strong><span style="color: #800000;">[username]</span></strong>') . "' WHERE id='8'",
                         "UPDATE " . $db_prefix . "info SET resize_imagesAllow = '1', default_imagesW = '400', default_imagesH = '400' WHERE id = '1'",
                         "DROP TABLE " . $db_prefix . "membergroup",
                         "DROP TABLE " . $db_prefix . "banned"
                         );

          foreach ($query as $key => $value)
          {
                   $query = $DB->sql_query($value);
                   if ($query)
                   {
                       $SF->msg("تمت العمليه #" . $key . "");
                   }
          }

          $insert6 = $DB->sql_query("INSERT INTO `" . $db_prefix . "toolbox` VALUES (29, 'Traditional Arabic', '1')");
          $insert6 = $DB->sql_query("INSERT INTO `" . $db_prefix . "toolbox` VALUES (30, 'Andalus', '1')");
          $insert6 = $DB->sql_query("INSERT INTO `" . $db_prefix . "toolbox` VALUES (31, 'Ms Sans Serif', '1')");
          $insert6 = $DB->sql_query("INSERT INTO `" . $db_prefix . "toolbox` VALUES (32, 'Impact', '1')");
          $insert6 = $DB->sql_query("INSERT INTO `" . $db_prefix . "toolbox` VALUES (33, 'Arial Black', '1')");
          $insert6 = $DB->sql_query("INSERT INTO `" . $db_prefix . "toolbox` VALUES (34, 'Verdana', '1')");
          $insert6 = $DB->sql_query("INSERT INTO `" . $db_prefix . "toolbox` VALUES (35, 'System', '1')");
          $insert6 = $DB->sql_query("INSERT INTO `" . $db_prefix . "toolbox` VALUES (36, 'Courier', '1')");

          $db = mysql_query("INSERT INTO " . $db_prefix . "contactus_messages(new) VALUES('3')");
          if (!$db)
          {
              if (mysql_errno() == 1054)
              {
                  $DB->sql_query("ALTER TABLE `" . $db_prefix . "contactus_messages` ADD new INT( 9 ) NOT NULL");
              }
              else
              {
                  $DB->sql_query("DELETE FROM `" . $db_prefix . "contactus_messages` WHERE new='3'");
              }
          }

          $db = mysql_query("INSERT INTO " . $db_prefix . "group(admincp_contactus) VALUES('3')");
          if (!$db)
          {
              if (mysql_errno() == 1054)
              {
                  $DB->sql_query("ALTER TABLE `" . $db_prefix . "group` ADD `admincp_contactus` INT( 1 ) NOT NULL");
              }
              else
              {
                  $DB->sql_query("DELETE FROM `" . $db_prefix . "group` WHERE admincp_contactus='3'");
              }
          }

          $meta =  addslashes('<meta http-equiv="Content-Type" content="text/html; charset=windows-1256" />
<meta http-equiv="Content-Language" content="ar" />
<meta name="keywords" content=" منتدى , منتديات, MySBB, MySmartBB, mymartbb, my smart bulletin board " />
<meta name="description" content="هذا المنتدى يستخدم برنامج MySmartBB لمعرفة المزيد عنه اذهب إلى www.mysmartbb.com" />');

          $insert8 = $DB->sql_query ("update " . $db_prefix . "info set meta='" . $meta . "'");
          $insert9 = $DB->sql_query("INSERT INTO `" . $db_prefix . "emailmsgs` VALUES (6, 'مشاركة جديدة بـ [title]', 'قام العضو [Replier] بالرد على موضوع <br /> <a href=http://[url]/show.php?main=1&id=[id]>[title]</a><br /> الذي طلبت بأن تكون مشترك فيه ..اذا اردت إلغاء اشتراكك <a href=http://[url]/usercp.php?keepmeon=1&id=[id]> اضغط هنا</a>')");

          $SF->install_msg('<br /><div align="center"><input type="submit" onclick="location.href=\'?step=2\'" value="الخطوة التالية" name="B1" /></div>');
      }


      if ($_GET['step'] == 2)
      {
          $member_num = $DB->sql_num_rows($DB->sql_query("SELECT * FROM " . $db_prefix . "member"));
          $lastmember_query = $DB->sql_query("SELECT * FROM " . $db_prefix . "member ORDER BY id DESC LIMIT 1");
          $lastmember_row   = $DB->sql_fetch_array($lastmember_query);

          $update_lastmember = $DB->sql_query("UPDATE " . $db_prefix . "info SET last_member='" . $SF->SafeSQL($lastmember_row['username']) . "',last_member_id='" . $lastmember_row['id'] . "',member_number='" . $member_num . "' WHERE id='1'");

          if ($update_lastmember)
          {
              $SF->msg('تم ضبط العدادات #1');
          }

          $subject_num = $DB->sql_num_rows($DB->sql_query("SELECT * FROM " . $db_prefix . "subject WHERE delete_topic<>'1'"));
          $reply_num = $DB->sql_num_rows($DB->sql_query("SELECT * FROM " . $db_prefix . "reply WHERE delete_topic<>'1'"));

          $update_srnum = $DB->sql_query("UPDATE " . $db_prefix . "info SET subject_number='" . $subject_num . "',reply_number='" . $reply_num . "'");

          if ($update_srnum)
          {
              $SF->msg('تم ضبط العدادات #2');
          }


          $forums = $SF->UpdateForumsArray();
          if ($forums)
          {
              $SF->msg('تم تحديث مصفوفة الاقسام بنجاح');
          }

          $groups = $SF->UpdateSectionGroupArray();
          if ($groups)
          {
              $SF->msg('تم تحديث مصفوفة المجموعات بنجاح');
          }

          $subs = $SF->UpdateSubForums();
          if ($subs)
          {
              $SF->msg('تم تحديث مصفوفة الاقسام الفرعيه بنجاح');
          }

          $reply = $SF->UpdateLastReplyArray();
          if ($reply)
          {
              $SF->msg('تم تحديث مصفوفة آخر رد بنجاح');
          }

          $smile = $SF->UpdateSmileArray();
          if ($smile)
          {
              $SF->msg('تم تحديث مصفوفة الابتسامات بنجاح');
          }

          $update = $DB->sql_query("UPDATE " . $db_prefix . "info SET MySBB_version='1.5.0' WHERE id='1'");

          if ($update)
          {
              $SF->msg("تم بفضل الله تعالى التحديث إلى الاصدار 1.5.0");
              $SF->msg("MySmartBB : نظره واثقه نحو المستقبل");
              $SF->msg("http://www.MySmartBB.com");
              $SF->error("يمكنك الإختيار بين الإستقرار على النسخة الحالية أو المتابعة . إختر لوحة التحكم للإستقرار");
              $SF->html('<br /><div align="center"><input type="submit" onclick="location.href=\'../admin/\'" value="لوحة التحكم" name="B1" /></div>');
			  $SF->html('<br /><div align="center"><input type="submit" onclick="location.href=\'update1.7.0.php\'" value="إكمال عملية التحديث إالى النسخة 1.7.0" name="B1" /></div>');

          }
      }

echo'<br />

        </td>
  </tr>
  <tr>
    <td class="footer">هذا المنتدى يعمل على برنامج <a href="http://www.mysmartbb.com">MySmartBB</a> | إعداد وبرمجة فريق MySmartBB
    </td>
  </tr>
</table>
</div>
</div>
</body>
</html>';

?>